# Lib-Ray Player
# Demonstration of launching, displaying, and parsing menus

from utils import *
from StringIO import StringIO

### MODEL
class enum(object):
    def __init__(self, items, doc="Enumerated Type with Values"):
	self.table = items
	self.__doc__ = doc
	for key in items:
	    setattr(self, key, key)
    def __repr__(self):
        rep = "%s:\n" % self.__doc__
	for val in self.table:
	    rep += ("\t%s\t%s\n" % (val, self.table[val]))
	return rep
	   
    
# Special Accessibility menu modes:
SpecialAccessibility = {
    'SKIPMENU':		'Play feature video immediately, as for children',
    'MUTEMENU':		'Turn off sound in menus',
    'COLORBLIND':	'Use colorblind-safe color scheme in menus',
    }
SA = enum(SpecialAccessibility,"Special Accessibility modes (change behavior of menus):")

# Region Codes:
RegionCode = {
    'TE':	"Global / Earth",
    'NA':	"North America",
    'SA':	"South America",
    'EU':	"Europe",
    'AF':	"Africa",
    'WA':	"West Asia",
    'EA':	"East Asia",
    'PA':	"Pacific",
    }
RC = enum(RegionCode, "Lib-Ray regions (to control language and locale menus):")

menu_defaults = StringIO("""\
[LibRayMenu]
languages: 0
locales: 0                                                                                                                                                                             
access:
region: TE
""")


class Menu(object):
    """
    State variable to indicate how menus are interpreted.
    
    @ivar menu_locale: Locales in decreasing order of preference. Determines
	details of menu display such as date-format or regional dialect.
    @type menu_locale: C{list} of ISO-3166 country codes (2-character C{str}) or C{None}.
	Default C{None}, meaning unset (Use disk origin locale).
                       
    @ivar menu_language: Languages in decreasing order of preference. Determines
        which menu labels will be displayed and allows for vocabulary substitution.
    @type menu_language: C{list} of ISO-639-x language codes (2- or 3-character C{str})
	or C{None}. Default C{None}, meaning unset (Use disk origin language).
	
    @ivar menu_region: Preferred geographical region code.
    @type menu_region: C{int} from enumerated values for Lib-Ray "Region Code"
    
    @ivar menu_access: Special Accessibility modes. Alters the presentation of
	menus to accommodate accessibility needs.
    @type menu_access: C{int} from enumerated values for Lib-Ray "Special Accessibility"
    """
    # Locale and language
    locales = None
    languages = None
    region = None
    access = None
    
    # Lib-Ray disk interface controls:
    names = ['locales', 'languages', 'region', 'access']
 
    def __init__(self, config):
        """
        Load initial defaults from the provided ConfigParser object.
        """
        self.locales = lazytype(config.get('LibRayMenu', 'locales'), multi=True)
        self.languages = lazytype(config.get('LibRayMenu', 'languages'), multi=True)
        self.region  = lazytype(config.get('LibRayMenu', 'region'))
        self.access  = lazytype(config.get('LibRayMenu', 'access'), multi=True)
    
    def relative_path(self):
        return '/index.html'
        
    def set_locales(self, value):
        raise NotImplemented
        
    def set_languages(self, value):
        raise NotImplemented
        
    def set_region(self, value):
        raise NotImplemented
        
    def set_access(self, value):
        raise NotImplemented

